const helper = new Helper(this);
const { proxy, baseRequest, selectView, handleMonitorData } = window._videoAccess;

selectView((monitorSelect) => {
    // 隐藏新增
    helper.getByCls('monitor-modal', false);
    // 打开确认弹窗
    helper.confirm('<div>视图删除后无法恢复，确认删除？</div>', {
        title: '确认',
        ok: async ($template) => {
            // 删除
            let res = await baseRequest(`/${proxy}SummaryAssessmentSV/videoView/delete?id=${monitorSelect.id}`);
            // 通过三维组件，关闭所有已经打开的视频
            helper.get('三维组件').widgetObj.sullivan.closeAll();
            if (res.success) {
                // 刷新数据
                handleMonitorData();
                layer.msg('删除成功!');
                // 卸载删除确认框
                $template.remove();
            } else {
                layer.msg(res.resultMessage || '操作失败');
            }
        },
        cancel() {
            window.layer?.msg('取消');
        }
    });
})

